package com.hotel.hotelsystem.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hotel.config.websocket.WebSocketProcess;
import com.hotel.couponsystem.mapper.CouponStockMapper;
import com.hotel.couponsystem.service.CouponStockService;
import com.hotel.customersystem.mapper.CustomerUserCouponMapper;
import com.hotel.hotelsystem.mapper.HotelListMapper;
import com.hotel.hotelsystem.pojo.HotelList;
import com.hotel.hotelsystem.service.HotelListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * (HotelList)表服务实现类
 *
 * @author makejava
 * @since 2022-09-30 18:23:16
 */
@Slf4j
@Service("hotelListService")
public class HotelListServiceImpl extends ServiceImpl<HotelListMapper, HotelList> implements HotelListService {
    // 酒店mapper
    @Resource
    private HotelListMapper hotelListMapper;
    // 优惠券库存mapper
    @Resource
    private CouponStockMapper couponStockMapper;

    @Resource
    private CouponStockService couponStockService;
    // 个人中心优惠券库存mapper
    @Resource
    private CustomerUserCouponMapper customerUserCouponMapper;

    // 导入redis组件库
    @Resource
    private RedisTemplate redisTemplate;

    // 导入消息队列组件
    @Resource
    private RabbitTemplate rabbitTemplate;

    // 导入消息推送组件
    @Resource
    private WebSocketProcess webSocketProcess;

    /**
     * 根据id删除酒店
     * @param hotelSelectId
     * @return
     */
    @Override
    public boolean deleteBySelectId(Integer hotelSelectId) {
        return hotelListMapper.deleteById(hotelSelectId)>0;
    }

    //分页查询
    @Override
    public IPage<HotelList> getByPage(Integer currentPage, Integer pageSize) {
//        LambdaQueryWrapper<HotelList> ldq = new LambdaQueryWrapper<>();
        Page<HotelList> page = new Page<>(currentPage,pageSize);
        System.out.println(page.getSize());
        IPage<HotelList> page2 = hotelListMapper.selectPage(page,null);
        return page2;
    }

}

